package com.panshi.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component;

import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

@Component
public class EmailPhoneUtill {

    @Autowired
    private org.springframework.mail.javamail.JavaMailSenderImpl JavaMailSenderImpl;

    @Value("${spring.mail.username}")
    private String myemail;

    //发送邮件审核通过表发送邮箱提示
    public void setemailarticle(String email,String title) throws MessagingException {
        //一个复杂的邮件
        MimeMessage mimeMessage=JavaMailSenderImpl.createMimeMessage();
        //组装
        MimeMessageHelper helper=new MimeMessageHelper(mimeMessage,true);
        helper.setSubject("渣男团的有贝口腔");
        helper.setText(title,true);//true支持html
        helper.setTo(email);
        helper.setFrom(myemail);
        JavaMailSenderImpl.send(mimeMessage);
    }
}